<template>
  <div style="padding: 0 15px;">
    <div style="padding:5px;">
      <a-space style="float: right;">
        <a-button @click="handleSearch()" type="primary">查询</a-button>
        <a-button type="primary" icon="plus-circle" @click="handleAdd">新增计划</a-button>
        <a-button>批量导入/导出</a-button>
        <a-button type="danger" ghost @click="batchDel">删除轮班</a-button>
      </a-space>
    </div>
    <div style="padding:5px;margin-top: 50px;">
      <a-table ref="table"
               bordered
               size="middle"
               rowKey="id"
               :columns="columns"
               :dataSource="dataSource"
               :pagination="ipagination"
               :loading="loading"
               :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
               @change="handleTableChange">
        <div slot="action" slot-scope="text,record">
            <div class="tableBtn">
              <a-button type="link" icon="form" @click="handleEdit(record)">编辑</a-button>
              <a-popconfirm
                title="确认要移除吗?"
                ok-text="是"
                cancel-text="否"
                @confirm="handleDelete(record.id)"
              >
                <a-button type="link" icon="delete" style="color: red;">删除</a-button>
              </a-popconfirm>
            </div>
        </div>
      </a-table>
    </div>
    <lunban-modal ref="modalForm" @ok="modalFormOk"></lunban-modal>
  </div>
</template>

<script>
import moment from 'moment'
import LunbanModal from './modules/LunbanModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
const path = '/crm_shift/crmShift'

const columns = [
  {
    title: '公司',
    dataIndex: 'company_dictText',
    align: 'center',
    key: 'company_dictText',
  },
  {
    title: '车间',
    dataIndex: 'workshop_dictText',
    align: 'center',
    key: 'workshop_dictText',
  },
  {
    title: '工序',
    dataIndex: 'workingProcedure_dictText',
    align: 'center',
    key: 'workingProcedure_dictText',
  },
  {
    title: '起始班次',
    dataIndex: 'shiftInit_dictText',
    align: 'center',
    key: 'shiftInit_dictText',
  },
  {
    title: '班制',
    dataIndex: 'shiftType_dictText',
    align: 'center',
    key: 'shiftType_dictText',
  },
  {
    title: '执行时间',
    align: 'center',
    key: 'startTime',
    customRender: (text, record) => `${record.startTime} - ${record.endTime}`
  },
  {
    title: '操作',
    align: 'center',
    key: 'action',
    scopedSlots: { customRender: 'action' },
  },
]

export default {
  inject: ['selectQuery'],
  mixins: [JeecgListMixin],
  components: { LunbanModal },
  data() {
    return {
      currentMonth: moment(),
      title: '',
      queryParam: {
        planTime:moment().format('YYYY-MM-DD')
      },
      columns,
      url: {
        list: path + '/list',
        delete: path + '/delete',
        deleteBatch: path + '/deleteBatch',
      }
    }
  },
  mounted() {

  },
  methods: {
    handleSearch() {
      this.queryParam.workshop = this.selectQuery.workshop
      this.queryParam.workingProcedure = this.selectQuery.workingProcedure
      this.searchQuery()
    },
  }
}
</script>

<style scoped>
.tableBtn .ant-btn {
  padding: 0 8px;
}
</style>